package com.sky.mapper.admin;

import com.github.pagehelper.Page;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.pojo.Courier;
import com.sky.pojo.Orders;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Service;

@Mapper
public interface OrderMapper {
    Page<OrderVO> findBYPage(OrdersPageQueryDTO pageQueryDTO);

    @Select("select count(*) from orders where status = #{status}")
    Integer countStatus(Integer status);

    OrderStatisticsVO countCaseStatus();

    @Select("select * from orders where id = #{id}")
    Orders findById(Long id);

    @Select("select tc.* from tb_courier tc left join tb_courier_trade_order tcto on tcto.courier_id = tc.id where tcto.order_number = #{orderNumber}")
    Courier findCourierByOrderNumber(String orderNumber);

    void updateOrder(Orders orders);

    @Select("select * from orders o join tb_courier_trade_order tcto on tcto.order_number = o.`number` where tcto.trade_no = #{tradeNo}")
    Orders getByTradeNo(Long tradeNo);
}
